package com.itheima.sh.controller;

import com.itheima.sh.client.UserFeignApi;
import com.itheima.sh.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import java.util.Map;

@RestController
@RequestMapping("feign")

public class FeignController {
    @Autowired
    UserFeignApi userFeignApi;

    @GetMapping("{id}")
    public User findUser(@PathVariable("id") String username) {
//        if (username.equals("itheima")) {
//            throw new RuntimeException("feign");
//        }

        return userFeignApi.queryById(username);
    }

}
